/**
 *
 */
package com.naiterui.ehp.bs.doctor.repository;

import com.naiterui.common.repository.core.BaseJpaRepository;
import com.naiterui.ehp.bp.domain.DrMessageConsultOrder;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.Collection;
import java.util.Date;
import java.util.List;

/**
 * 医生图文咨询订单持久层
 * @author xuchong
 * @since 2.7.0
 */
@Repository
public interface IDrMessageConsultOrderRepository extends BaseJpaRepository<DrMessageConsultOrder, Long>  {

    @Modifying
    @Query(value = "update dr_message_consult_order set consult_session_status=?1,changed_at=?2 where session_id=?3", nativeQuery = true)
    void updateMessageConsultOrderSessionStatusBySessionId(Integer sessionStatus, Date changedAt, String sessionId);


    /**
     * sessionId ，支付状态，批量查询图文咨询订单
     *
     * @return
     */


    List<DrMessageConsultOrder> findBySessionIdInAndPayStatusIn(Collection<String> sessionIds, Collection<Integer> status);

    List<DrMessageConsultOrder> findByConsultSessionIdIn(Collection<Long> sessionIds);

    @Query(value = "select * from dr_message_consult_order where pay_status=2 and doctor_id=?1 ", nativeQuery = true)
    List<DrMessageConsultOrder> findByDoctorId(Long doctorId);

}
